package com.ruoyi.orderdoctor.service.impl;

import java.util.List;

import com.ruoyi.orderdoctor.domain.vo.OrderDoctorVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.orderdoctor.mapper.OrderDoctorMapper;
import com.ruoyi.orderdoctor.domain.OrderDoctor;
import com.ruoyi.orderdoctor.service.IOrderDoctorService;

/**
 * 【订单医生关联表】Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-03
 */
@Service
public class OrderDoctorServiceImpl implements IOrderDoctorService 
{
    @Autowired
    private OrderDoctorMapper orderDoctorMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param orderId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public OrderDoctor selectOrderDoctorByOrderId(Long orderId)
    {
        return orderDoctorMapper.selectOrderDoctorByOrderId(orderId);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param orderDoctor 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<OrderDoctor> selectOrderDoctorList(OrderDoctor orderDoctor)
    {
        return orderDoctorMapper.selectOrderDoctorList(orderDoctor);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param orderDoctor 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertOrderDoctor(OrderDoctor orderDoctor)
    {
        return orderDoctorMapper.insertOrderDoctor(orderDoctor);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param orderDoctor 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateOrderDoctor(OrderDoctor orderDoctor)
    {
        return orderDoctorMapper.updateOrderDoctor(orderDoctor);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param orderIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteOrderDoctorByOrderIds(Long[] orderIds)
    {
        return orderDoctorMapper.deleteOrderDoctorByOrderIds(orderIds);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param orderId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteOrderDoctorByOrderId(Long orderId)
    {
        return orderDoctorMapper.deleteOrderDoctorByOrderId(orderId);
    }

    /**
     * 推荐医生
     *
     * @param orderDoctorVO
     * @return
     */
    @Override
    public String insertOrderDoctorVO(OrderDoctorVO orderDoctorVO) {
        String orderId = orderDoctorVO.getOrderId();
        List<Long> doctorIds = orderDoctorVO.getDoctorIds();
        for (Long doctorId : doctorIds) {
            OrderDoctor orderDoctor = new OrderDoctor();
            orderDoctor.setOrderId(orderId);
            orderDoctor.setDoctorId(doctorId);
            orderDoctorMapper.insertOrderDoctor(orderDoctor);
        }
        return "推荐成功";
    }
}
